home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 194_01 / swtools.doc < prev    next >
INI File  |  1985-11-13  |  7KB  |  169 lines

  1. [SWTOOLS.DOC of JUGPDS Vol.17]
  2.  
  3.                          Software Tools in BDS C
  4.  
  5.                               June 2, 1985
  6.  
  7.                    Hakuou KATAYOSE (JUG-CP/M No.179)
  8.                     49-114 Kawauchi-Sanjuunin-machi, 
  9.                        Sendai, Miyagi 980, Japan
  10.                            Phone: 0222-61-3219
  11.   
  12.  
  13. 1. Introduction
  14.      Here  is  yet  another  version  of  Software  Tools  (Kernighan & 
  15. Plauger) in C (mostly in BDS C).  The original source programs in Ratfor 
  16. have been translated into C. Also included are some utilities to compile 
  17. and to demonstrate the application of the tools.
  18.  
  19. 2.  Programs from Software Tools
  20.     I have implemented almost every program in  Software Tools except
  21. for those in Chapter 6 "EDITING" and  Chapter 9 "A RATFOR-FORTRAN 
  22. TRANSLATOR".
  23.  
  24. ------------------------------------------------------------------------
  25. Program Name           Description (Page of the original K&P book)
  26. ------------------------------------------------------------------------
  27. COUNT              (charcount +  linecount + wordcount) (p12,13,15)
  28. DETAB/ENTAB        Handling of TAB (p20,37)
  29. OVERSTRIK          Overstrike of a line (p40)
  30. COMPRESS/EXPAND    Compression and expansion of a text (p44,48)
  31. CRYPT0,CRYPT1      Encrypt of a text file. Note that a encrypt file may
  32.            contain EOF marks; 0X01A(control-Z).  CRYPT1 is to
  33.            handle a binary file, it lacks the pipe and I/O
  34.            redirection facilities of CRYPT0. I would recommend
  35.            CRYPT1 as the more reliable. 
  36. TRANSLIT           Character transliteration (p56)  
  37. COMPARE            Comparison of two files (p70,73)
  38. CONCAT0,COMCAT1    Concatenation of text files (p78)
  39. ARCHIVE            File archiver (p88)        
  40. MSORT,SORT         Sorting of a text file. MSORT can handle up to about
  41.            2000 lines or 30k bytes. SORT is for sorting with
  42.            merge.
  43. UNIQUE             Stripping adjacent duplicate lines (p125)   
  44. KWIC/UNROT         Keyword in context index (p128,131)
  45. FRQNCY           Word frequency list for a document file (p126) 
  46. FIND/CHANGE       Find (grep) and change patterns in text (p139,156)
  47. FORMAT           Text formatter (p234)
  48. MACRO           Expand macros with arguments (p270)
  49. ------------------------------------------------------------------------
  50.  
  51.      To compile and link the source programs described  above, you will
  52. need  to include some header files (DEF.H, STDIO.H) and the  function 
  53. libraries DEFF3.CRL and PAT.CRL.  [The source for all four is included
  54. in JUGPDS Vol.17]
  55.  
  56.  
  57. 3. Some Notes on Translating Software Tools from Ratfor to C
  58.      Since  Ratfor  is  a  preprocessor for  Fortran,   the  parameters 
  59. (arguments) for FUNCTIONs and SUBROUTINEs  are referenced by address -- 
  60. pointers in the C language.  You cannot pass arguments by value unless
  61. you make appropriate changes to the C functions.
  62.  
  63.      The  next  point to watch is the difference of arrays.  Fortran 
  64. arrays start with element 1; C start at 0.  If you declare A(50), you 
  65. have the Ratfor array A(1)-A(50),  but A[0]-A[4] in C.  This difference
  66. is important when you specify  the limits for a loop counter.  
  67. Fortran-77  gives  greater  compatibility  because it allows  you  to 
  68. declare A(0:49).
  69.      Also note that the elements of multi-dimensional arrays are stored
  70. in different orders -- by column in Fortran, by row in C.
  71.  
  72.         Fortran ... A(1,1),A(2,1),A(3,1),...
  73.         C       ... A[0][0],A[0][1],A[0][2],...
  74.  
  75. So you have to exchange column and row for a two-dimensional array, if 
  76. you want to use C pointers.
  77.  
  78. 4. How to Use @D
  79.      This  program is an application of FRQNCY.C.  The general form  to 
  80. evoke the program is:
  81.  
  82.     @D {u/} {d:} {file}{.ext}
  83.  
  84. where u/: user no., ? means all user numbers,
  85.       d:  Disk drive name (A-P)
  86.  
  87.      The simplest form  '@D',  is  almost the same as DIR command -- 4
  88. filenames per row -- except that it also gives user number and filesize.
  89. Like DIR, it recognizes the CP/M wild card ('* and '?') for file and 
  90. extension names.  The filenames are sorted into alphabetical order.
  91.  
  92.      The  command  '@D ?/' lists all files for all  users.   @D  does 
  93. not mask the filename bits.  If a file has been marked SYS or $R/O, the 
  94. first  character of file extension will appeared in Kana [provided your
  95. CRT hardware or BIOS does not automatically mask the highest bit.  M.H.]
  96.  
  97. 5. How to Use DOCTOR
  98.      Compile and link DOCTOR.C with the following commands:
  99.         CC DOCTOR
  100.         L2 DOCTOR DISPLAY
  101.  
  102. [This has been done. 
  103. *** WARNING:  This tool writes directly to the disk.  Practice with a
  104.     garbage disk first! *** Y.M.]
  105.  
  106.      DOCTOR.COM signs on with the following prompt: 
  107.         Disk:=
  108. Enter the letter for the drive you want to edit.  DOCTOR will  then 
  109. display the first part of  logical sector 0,  the disk directory on
  110. the CRT.
  111.  
  112. Commands:
  113. [D]    Dd    specify Drive d (d is A-P)
  114. [T]    T#    move to Track # (#is a decimal number)
  115. [S]    S#    move to Sector #
  116. [B]    B#    move to Block #
  117. [E]    E    Exit from DOCTOR
  118. [C]    C    fill current sector with 00H
  119. [I]    I    fill current sector with E5H
  120. [L]    L    exchange of Logical and Physical sector
  121. [+] or [;]    increment sector # (either '+' or ';' is OK)
  122. [-] or [=]    decrement sector #
  123. [>] or [.]    increment track #
  124. [<] or [,]    decrement track #
  125. [[] or [{]    increment block #
  126. []] or [}]    decrement Block #
  127. [A] or [H]    edit sector using ANK [A] or HEX [H]
  128.  
  129.              A edit command moves the cursor to the home position 
  130.         of the sector display.  You can either move the cursor
  131.         -- with the WordStar cursor controls shown below --
  132.         or modify the byte under the cursor by entering the 
  133.         new value.
  134.  
  135.                    ^W
  136.                 I    
  137.                       ^S -- Ñ -- ^D
  138.                 I
  139.                        ^X
  140.  
  141. [ESC]        End edit. [ESC] [X] aborts the edit without saving the 
  142.         changes to disk.  
  143. [Q]        Quick. As currently define (16 +-signs), this command
  144.         increments the sector number 16 times.
  145.  
  146. ------------------------------------------------------------------------
  147. NOTES 
  148.      The [ESC] and cursor movement keys can be redefined in the source 
  149. program.  The  cursor addressing sequences must also be customized for
  150. your terminal.
  151.  
  152. [ Disk Editors comments:
  153.   The submitted disk contained only the source code.  I have prepared 
  154. and tested the .COM files with Kohjinsha's Micro Decision and BDC C 
  155. Ver 1.50a.  The one's for SORT.C and MACRO.C don't seem to work 
  156. properly.  I am not sure whether this is due to bugs in the source or
  157. the compiler. (The contributor used BDS C Ver 1.50.)  Please let us 
  158. know if you locate the source of the problem.
  159.   No attempt has been made to optimize the objective code for either
  160. speed or size.  I have also abbreviated some of the .COM filenames
  161. to save typing and to simulate UNIX-like environment. 
  162.  
  163. COMPRESS ---> CMPRS, EXPAND ---> EXPND, TRANSLIT ---> TR,
  164. COMPARE ---> CMP, CONCAT0 ---> CAT0, CONCAT1 ---> CAT1, MACRO ---> M4.
  165.  
  166.      Maynard Hogg (JUG-CP/M No.99) volunteered to improve this documen-
  167. tation.  Thank you Maynard.  Y.M.]
  168.  
  169.